Skip to content

refactor(streaming): noteUpdated payload を typed NoteUpdateBody に置き換える - #36

Merged
hitalin merged 2 commits into
mainfrom
refactor/typed-note-update-body
Jul 19, 2026
Merged

refactor(streaming): noteUpdated payload を typed NoteUpdateBody に置き換える#36
hitalin merged 2 commits into
mainfrom
refactor/typed-note-update-body

Conversation

@hitalin

@hitalin hitalin commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

なぜ

notedeck-dev/notedeck#781 Phase 1。ストリーミングイベント payload の serde_json::Value 素通しを specta 型付き契約に載せる移行の第一歩として、noteUpdated 系イベントの update_type: String + body: Value を typed enum に置き換える。フォーク差異による payload 揺れを Rust 側 normalize (WS 境界) に集約し、フロントの防御的コードを削減する土台。

変更内容

  • NoteUpdateBody enum (reacted / unreacted / pollVoted / deleted) + 各 body struct を models.rs に追加(specta cfg_attr は既存パターン踏襲)
  • StreamNoteUpdatedEvent / StreamNoteCaptureEventupdate_type + body#[serde(flatten)] update: NoteUpdateBody に置換 — ワイヤ形 { noteId, updateType, body } は不変(契約テストあり)
  • WS handler / polling diff の emit 箇所を typed 構築に変更
  • emoji の揺れ({ name, url } / bare string / null)は untagged ReactionEmoji で吸収
  • 未知の updateType は WS 境界で debug log とともに drop

テスト

  • note_update_body_* 4 件(from_raw の parse / 揺れ吸収 / unknown drop / ワイヤ形)
  • stream_note_updated_event_keeps_wire_shape(flatten 後のワイヤ形契約)
  • 既存 186 件全通過、clippy (--features specta --all-targets) クリーン

🤖 Generated with Claude Code

hitalin and others added 2 commits July 19, 2026 19:33
notedeck#781 Phase 1。StreamNoteUpdatedEvent / StreamNoteCaptureEvent の
update_type: String + body: Value を、adjacent tagging (updateType/body) の
NoteUpdateBody enum に置き換える。serde(flatten) により歴史的ワイヤ形
{ noteId, updateType, body } は不変で、specta feature 有効時は TS の
discriminated union として bindings に載る。

- reacted / unreacted / pollVoted / deleted の 4 variant + 各 body struct
- emoji は { name, url } / bare string / null のフォーク揺れを
  untagged ReactionEmoji で吸収
- 未知の updateType (フォーク拡張) は WS 境界で debug log とともに drop
  (Inspector の raw tap には影響しない)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
body を省略するフォークで noteUpdated deleted が握り潰されると
ゴーストノートが残るため、null は空 body として扱う。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hitalin hitalin self-assigned this Jul 19, 2026
@hitalin
hitalin merged commit 01c8c14 into main Jul 19, 2026
1 check passed
@hitalin
hitalin deleted the refactor/typed-note-update-body branch July 19, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant